package com.min.redis.application.managetment.util;

public class RankKeyUtil {

    private static final long SECOND_TIME = 1000;
    private static final long MINUTE_TIME = 60*1000;
    private static final long HOUR_TIME = 60*60*1000;
    private static final long DAY_TIME = 24*60*60*1000;
    private static final long WEEK_TIME = 7*24*60*60*1000;

    public static long rankMinuteKey(){
        return getTimeKey(MINUTE_TIME);
    }

    public static long rankHourKey(){
        return getTimeKey(HOUR_TIME);
    }
    public static long rankDayKey(){
        return getTimeKey(DAY_TIME);
    }

    public static long rankWeekKey(){
        return getTimeKey(WEEK_TIME);
    }

    /**
     * 返回key
     * @param time
     * @return
     */
    public static long getTimeKey(long time){
        long timestamp = System.currentTimeMillis();
        return timestamp/time;
    }
}
